The contents of Japanese Patent Application No. 11-31622 filed on Nov., 1999 in Japan, are incorporated herein by reference.
1. Field of the Invention
The present invention relates to a debugging method and apparatus for multitask programs, as well as to a recording medium storing a program used for realization of the debugging method and apparatus. More particularly, the present invention relates to a debugging method and apparatus which enables each of selected tasks to be stopped at an arbitrary target program position, as well as to a recording medium storing a program used for realization of such a debugging method and apparatus.
With the recent decrease in price of CPUs due to development of computer-related techniques, an increasing number of computer systems have employed a plurality of CPUs. Further, in order to effectively use a plurality of CPUs, in an increasing number of cases such a computer system has used a multitask program in which a plurality of tasks are performed concurrently and in parallel in order to execute a single job.
Multitask programs are divided into a multithread program which executes in parallel a plurality of interdependent threads in a process, and a multiprocess program which executes in parallel a plurality of interdependent processes. An examples of the multiprocess program include a network parallel program in which a plurality of processes are executed on a plurality of computer systems in a distributed manner.
In order to properly operate such a multitask program formed of a plurality of interdependent tasks, the plurality of selected tasks must be synchronized at a proper timing (program position). If this synchronization is not established, the multitask program does not operate properly.
In view of the foregoing, there has been demand for a debugging technique for multitask programs which effectively determines whether a plurality of selected tasks are synchronized at a proper timing.
2. Description of the Related Art
Japanese Patent Application Laid-Open (kokai) No. 2-300942 discloses an existing debugging technique for multitask programs in which a plurality of tasks are concurrently executed in parallel. In the technique, when execution of any one of a plurality of tasks designated among tasks which operate on an operating system is stopped (at a breakpoint set by a debugger), the remainder of the designated tasks are stopped at the same time.
Japanese Patent Application Laid-Open (kokai) No. 4-314141 discloses a multitask control technique. According to the multitask control technique, for the purpose of debugging, when an arbitrary task constituting a multitask job reaches a previously set stop point or when an exception occurs, all tasks belonging to the same multitask job group as the arbitrary task are stopped. Further, execution of all the tasks of the multitask job group is resumed at an arbitrary point in time.
Although not relating directly to debugging processing, Japanese Patent Application Laid-Open (kokai) No. 63-4339 discloses a technique for controlling a plant by use of a plurality of tasks which constitute plant control. In order to overcome a drawback such that a system of a plant which is not required to stop is stopped undesirably, tasks are managed in order to form a task group which includes tasks which must be stopped concurrently upon stoppage of any one of the tasks. In the task managing technique, when, in response to detection of an anomalous state, an operating system stops a task belonging to a certain group, the remaining tasks of the same group are stopped.
However, use of such an existing debugging technique makes it impossible to realize barrier synchronization which enables each of selected tasks to stop at an arbitrary target program position.
That is, the existing techniques disclosed in the above-described Japanese Patent Application Laid-Open Nos. 2-300942 and 4-314141 employ a configuration such that when execution of any one of grouped tasks is stopped, the remaining tasks of the group are stopped concurrently. Therefore, barrier synchronization which enables each of selected tasks to be stopped at an arbitrary target program position cannot be realized.
Such barrier synchronization becomes necessary for debugging of a multitask program in which a plurality of tasks perform initialization processing or calculation processing, each task taking partial charge of the processing.
One conceivable method for realizing such barrier synchronization is such that a barrier synchronization mechanism is built in a multitask program to undergo debugging, through rewriting thereof; a breakpoint is set (an instruction for stopping the program is embedded) at a program position at which barrier synchronization is guaranteed to be completed; and the multitask program is executed up to that position.
However, when this method is employed, a multitask program to undergo debugging must be rewritten for insertion of a barrier synchronization mechanism. In some cases this may hide the real cause of an anomaly. Further, when a barrier synchronization mechanism to be inserted has a defect, there arise various problems, such as necessity of work for searching the defect, or generation of a new bug.
In view of the above-described problems, a first object of the present invention is to provide a new debugging method and apparatus for a multitask program which enables each of selected tasks to be stopped at an arbitrary target program position.
A second object of the present invention is to provide a program recording medium which stores therein a program used for realization of the debugging method and apparatus.
A third object of the present invention is to provide a debugging method and apparatus which can perform debugging efficiently, as well as a program recording medium which stores therein a program used for realization of such a debugging method and apparatus.
A fourth object of the present invention is to provide a debugging apparatus which can perform debugging on the basis of barrier synchronization, while matching the sequence of execution of programs.
In order to achieve the above objects, the present invention provides a debugging apparatus for debugging a multitask program. It comprises setting means for setting a barrier synchronization point which groups a breakpoint set for each of a plurality of tasks; judgment means operating each time a different one of the tasks stops at a corresponding breakpoint, in order to judge whether all tasks having breakpoints belonging to the barrier synchronization point have stopped at the respective breakpoints; resumption means operating, upon judgment by the judgment means that not all the tasks have stopped, in order to bring a newly stopped task into a suspended state and then resume execution of a multithread program; and control means for bringing the suspended tasks back to an executable state when the judgment means judges that all the tasks have stopped.
Preferably, the debugging apparatus of the present invention further comprises specifying means for specifying a barrier synchronization point which includes a breakpoint having first stopped a task. When a task stops at a breakpoint belonging to the specified barrier synchronization point, the judgment means judges whether all tasks having breakpoints belonging to the barrier synchronization point specified by the specifying means have stopped at the respective breakpoints.
In order to achieve the above objects, the present invention provides a debugging method for debugging a multitask program. It comprises setting a barrier synchronization point which groups a breakpoint set for each of a plurality of tasks; each time a different one of the tasks stops at a corresponding breakpoint, judging whether all tasks having breakpoints belonging to the barrier synchronization point have stopped at the respective breakpoints; upon judgment that not all the tasks have stopped, bringing a newly stopped task into a suspended state and then resuming execution of a multithread program; and bringing the suspended tasks back to an executable state when all the tasks are judged to have stopped.
Preferably, the debugging method of the present invention further comprises specifying a barrier synchronization point which includes a breakpoint having first stopped a task. When a task stops at a breakpoint belonging to the specified barrier synchronization point, judgment is performed as to whether all tasks having breakpoints belonging to the specified barrier synchronization point have stopped at the respective breakpoints.
In order to achieve the above objects, the present invention provides a program recording medium storing a program for realizing a debugging apparatus for multitask programs, the program causing a computer to perform: setting processing for setting a barrier synchronization point which groups a breakpoint set for each of a plurality of tasks; judgment processing, each time a different one of the tasks stops at a corresponding breakpoint, in order to judge whether all tasks having breakpoints belonging to the barrier synchronization point have stopped at the respective breakpoints; resumption processing, upon judgment by the judgment processing that not all the tasks have stopped, in order to bring a newly stopped task into a suspended state and then resume execution of a multithread program; and control processing for bringing the suspended tasks back to an executable state when the judgment processing judges that all the tasks have stopped.
Preferably, the program stored in the program recording medium further comprises specifying processing for specifying a barrier synchronization point which includes a breakpoint having first stopped a task. When a task stops at a breakpoint belonging to the specified barrier synchronization point, the judgment processing judges whether all tasks having breakpoints belonging to the barrier synchronization point specified by the specifying processing have stopped at the respective breakpoints.
The present invention further provides a debugging apparatus for debugging a multitask program, comprising: a setting unit for setting a barrier synchronization point which groups a breakpoint set for each of a plurality of tasks; a judgment unit operating each time a different one of the tasks stops at a corresponding breakpoint, in order to judge whether all tasks having breakpoints belonging to the barrier synchronization point have stopped at the respective breakpoints; a resumption unit operating, upon judgment by the judgment unit that not all the tasks have stopped, in order to bring a newly stopped task into a suspended state and then resume execution of a multithread program; and a control unit for bringing the suspended tasks back to an executable state when the judgment unit judges that all the tasks have stopped.
Preferably, the debugging apparatus of the present invention further comprises a specifying unit for specifying a barrier synchronization point which includes a breakpoint having first stopped a task. When a task stops at a breakpoint belonging to the specified barrier synchronization point, the judgment unit judges whether all tasks having breakpoints belonging to the barrier synchronization point specified by the specifying unit have stopped at the respective breakpoints.
Alternatively, the debugging apparatus of the present invention may be formed of the following units. That is, the debugging apparatus for multitask programs comprises a setting unit for setting a barrier synchronization point which groups a specific operation point, such as a breakpoint, set for each of a plurality of tasks; and an analysis position processing unit operating, when a task performs a specific operation at a corresponding operation point in order to bring into a suspended state all tasks having operation points belonging to the barrier synchronization point, and then bringing the suspended tasks back to an executable state.